/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import geolocation from '@ohos.geolocation'

export class MyAbilityStage  {
    public locationResult = '运行结果'

    public info =  {
        priority : 0x200,
        scenario : 0x300,
        timeInterval : 1
    }

    public location = {
        latitude : 1,
        longitude : 1,
        altitude : 1,
        accuracy : 1,
        speed : 1,
        timeStamp : 1,
        direction : 1,
        timeSinceBoot : 1,
        additions : "202",
        additionSize : 20,
        isFromMock  : false
    }

    public info2 = [this.location]

    enableLocationMock() {
        geolocation.enableLocationMock(this.info, (err, result) => {
            console.log("enableLocationMock" + ': err:' + err + " enableLocationMock result: " + result)
            this.locationResult = "enableLocationMock" + ': err:' + err + " enableLocationMock result: " + result
        })
    }

    disableLocationMock() {
        geolocation.disableLocationMock(this.info, (err, result) => {
            console.log("disableLocationMock" + ': err:' + err + " disableLocationMock result: " + result)
            this.locationResult = "disableLocationMock" + ': err:' + err + " disableLocationMock result: " + result
        })
    }

    setMockedLocations() {
        geolocation.setMockedLocations(this.info,this.info2, (err, result) => {
            console.log("setMockedLocations" + ': err:' + err + " setMockedLocations result: " + result)
            this.locationResult = "setMockedLocations" + ': err:' + err + " setMockedLocations result: " + result
        })
    }
}